return true;
     }
 
-    /* don't record commands in history runed by autocmd */
-    vb.state.enable_history = false;
-
     /* loop over the groups and find matching commands */
     for (lg = groups; lg; lg = lg->next) {
         grp = lg->data;
             ex_run_string(cmd->excmd);
         }
     }
-    vb.state.enable_history = true;
 
     return true;
 }
 
 {
     const char *file;
 
-    /* don't write a history entry to the file if history is disabled or
-     * history max size is set to 0 */
-    if (!vb.state.enable_history || !vb.config.history_max) {
+    /* Don't write a history entry to the file if the commands where not typed
+     * by the user or the history max size is set to 0. */
+    if (!vb.config.history_max || !vb.state.typed) {
         return;
     }
 
 }
 
 /**
- * Loads history items form file but eliminate duplicates in FIFO order.
+ * Loads history items form file but eleminate duplicates in FIFO order.
  *
  * Returned list must be freed with (GDestroyNotify) free_history.
  */
 
         g_error_free(err);
     }
 
-    /* don't recore remote commands in history */
-    vb.state.enable_history = false;
+    /* simulate the typed flag to allow to record the commands in history */
+    vb.state.typed = true;
 
     map_handle_string(line, true);
     g_free(line);
 
-    /* reenable history recording */
-    vb.state.enable_history = true;
+    /* unset typed flag */
+    vb.state.typed = false;
 
     return true;
 }
 
 
     /* init some state variable */
     vb.state.enable_register = false;
-    vb.state.enable_history  = false;
     vb.state.uri             = g_strdup("");
 
     init_core();
 
     /* active the registers and writing of command history */
     vb.state.enable_register = true;
-    vb.state.enable_history  = true;
 
     /* open uri given as last argument */
     if (argc <= 1) {
 
     char            *reg[VB_REG_SIZE];      /* holds the yank buffer */
     gboolean        enable_register;        /* indicates if registers are filled */
     char            current_register;       /* holds char for current register to be used */
-    gboolean        enable_history;         /* indicates if history entries are written */
+    gboolean        typed;                  /* indicates if th euser type the keys processed as command */
 #ifdef FEATURE_SEARCH_HIGHLIGHT
     int             search_matches;         /* number of matches search results */
 #endif
 
         return false;
     }
 
+    /* set flag to notify that the key was typed by the user */
+    vb.state.typed         = true;
     vb.state.processed_key = true;
+
     map_handle_keys(string, len, true);
 
+    /* reset the typed flag */
+    vb.state.typed = false;
+
     return vb.state.processed_key;
 }
 
             ) {
                 map.resolved = match->inlen;
             }
+            /* Unset the typed flag - if there where keys replaced by a
+             * mapping the resulting key string is considered as not typed by
+             * the user. */
+            vb.state.typed = false;
         } else {
             /* first char is not mapped but resolved */
             map.resolved = 1;